
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>首页</title>
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.js"></script>

    <script type="text/javascript">
      $(function () {
        function c() {
          $.post({
            url:"${pageContext.request.contextPath}/h2",
            data:{"name":$("#username").val()},
            success:function (data) {
              alert(data);
            }
          })
        }
      })


    </script>
  </head>
  <body>

<%--  失去焦点时发送一个请求(携带信息)到后台--%>
<%--onblur：失去焦点事件--%>
  <input type="text" id="username" onblur="c()">

  <a href="test2.jsp">跳转至test2.jsp</a>
  <br>
  <a href="login.jsp">前往登录</a>
  </body>
</html>
